package com.cn.dai.common;

import com.cn.dai.common.JwtToken;

public class JwtHolder {
    public static final ThreadLocal<JwtToken> jwtTokenHolder = new ThreadLocal<>();
    public static void setLocal(JwtToken jwtToken){
        jwtTokenHolder.set(jwtToken);
    }
    public static JwtToken getLocal(){
        JwtToken jwtToken = jwtTokenHolder.get();
        if (jwtToken == null){
            //todo 改成自定义异常处理类
            throw new RuntimeException();
        }
        return jwtToken;
    }
    public static void moveLocal(){
        if (jwtTokenHolder.get()!= null){
            jwtTokenHolder.remove();
        }
    }
}
